package jsu.blogger.mapper;


import org.apache.ibatis.annotations.*;

@Mapper
public interface DraftTagMapper {

    // 根据标签名查找 tag_id
    @Select("SELECT tag_id FROM tags WHERE tag_name = #{tagName}")
    Long findTagIdByTagName(@Param("tagName") String tagName);

    // 根据 draft_id 删除所有标签
    @Delete("DELETE FROM draft_tags WHERE draft_id = #{draftId}")
    void deleteByDraftId(@Param("draftId") String draftId);

    // 插入草稿和标签的关联
    @Insert("INSERT INTO draft_tags (draft_id, tag_id) VALUES (#{draftId}, #{tagId})")
    void insertDraftTag(@Param("draftId") String draftId, @Param("tagId") Long tagId);
}
